import { _decorator, Color, Label, Layout, Node, RichText, UITransform } from 'cc';
import { ScrollView } from 'cc';
import { DataItemComponent, DataItemLayout } from '../../../Core/DataItemLayout';
const { ccclass, property } = _decorator;

@ccclass('MailBoxItem')
export class MailBoxItem extends DataItemComponent<{title:string, body:string, items:{icon:number, quality:number, count:number}[]}> {
    @property(Label)
    titleLabel : Label;

    @property(RichText)
    rt : RichText;
    
    @property(UITransform)
    expandTrans : UITransform;

    @property(DataItemLayout)
    itemsLayout : DataItemLayout;

    @property(ScrollView)
    sv : ScrollView

    protected setData(data: {title:string, body:string, items:{icon:number, quality:number, count:number}[]}) {
        this.titleLabel.string = data.title
        this.rt.string = data.body
        this.itemsLayout.bindDatas(data.items)

        this.sv.enabled = data.items.length >= 5
    }

    refToggleType(isSelect: boolean) {
        if(isSelect){
            this.changeExpand(155 + this.expandTrans.height)
        }else{
            this.changeExpand(155)
        }
        this.expandTrans.node.active = isSelect
    }
    
}


